//*********************************************
//  This is Geant4 Template
//                                  author:Qian
//

#ifndef MySingleCsIAnalysis_h
#define MySingleCsIAnalysis_h 1

#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Event.hh"
#include "globals.hh"
#include <iomanip>
#include "MyBasedAnalysis.hh"

class TH1F;
class MyDetectorConstruction;
class MyEvtAction;
class MyRunAction;
class MyBasedAnalysis;

class MySingleCsIAnalysis: public MyBasedAnalysis
{
public:
    MySingleCsIAnalysis();
    ~MySingleCsIAnalysis();

    void BeginOfEventAction(const G4Event *evt);
    void EndOfEventAction(const G4Event *evt);

    void BeginOfRunAction();
    void EndOfRunAction();

    G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack);
    void SteppingAction(const G4Step *aStep);
    void PreTrackingAction(const G4Track *aTrack);
    void PostTrackingAction(const G4Track *aTrack);

    inline void SetFileName(G4String fname) { fFileName = fname; }
    inline void Activated() { active = true; }
    inline void Deactivated() { active = false; }
    inline bool IsActivated() { return active; }

    inline void SetDetectorConstruction(MyDetectorConstruction *det) { fDetector = det; }
    inline void SetRunAction(MyRunAction *run) { fRunAction = run; }
    inline void SetEvtAction(MyEvtAction *evt) { fEvtAction = evt; }

private:
    bool active = false;
    G4String fFileName;
    MyDetectorConstruction *fDetector;
    MyRunAction *fRunAction;
    MyEvtAction *fEvtAction;
    //#ANALYSIS 0. 定义用户变量
private:
    double fTrkLen;
    std::vector<double> fEdeps;
    std::vector<double> fHitsX;
    std::vector<double> fHitsY;
    std::vector<double> fHitsZ;
    std::vector<double> Eng_MSC;
    std::vector<double> Eng_Ei;
    std::vector<double> Eng_SC;
    std::vector<double> Eng_Pho;
    std::vector<double> Eng_e_1_dop;
    std::vector<double> Eng_g_1_dop;
    std::vector<double> Eng_e_1;
    std::vector<double> Eng_g_1;
    std::vector<double> Eng_g_0_dop;
    
    int num_mod_0;
    int num_mod_1;
    int mod;
    double Eng_e_sum;
    double Eng_g_sum;
    double Eng_g_0_dop_sum;
    
    int Nhits;
    int Nhits1;
    int Nhits2;
    int Nhits3;
    int Nhits4;
    int num;
    int proNum;
    int MSC;
    int EIoni;
    int SCintillation;
    int Sum;
    int E_num;
    double Energy;
    int Select;
    double Eng_Pho_all;
    double Eng_Ele_Lose;
    double Gamma_Euger;
    double Gamma_Fluo;
    double Gamma_PIXE;
    double E_PIXE;
    double E_Fluo;
    double E_Euger;
    double gamma_dep;
    double e_eng;
    double opt_eng;
    

    int fPhotoGamma;
    int fComptGamma;
    int fPhotoAuger;
    int fComptAuger;
    int fPixeGamma;
    int fPixeAuger;

    int fElectronDNAGamma;
    int fElectronDNAAuger;
    int fProtonDNAGamma;
    int fProtonDNAAuger;
    int fHydrogenDNAGamma;
    int fHydrogenDNAAuger;
    int fAlphaDNAGamma;
    int fAlphaDNAAuger;
    int fAlphaPlusDNAGamma;
    int fAlphaPlusDNAAuger;
    int fHeliumDNAGamma;
    int fHeliumDNAAuger;
    int fGenericIonDNAGamma;
    int fGenericIonDNAAuger;

    bool fIDdefined;
    
};

#endif